package org.sdp.pearproject.dao.domain;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * InterfaceName: ProjectForNotifyNoReadsCountExample
 * @Description:
 * @Author: SDP
 * @Date: 2022-07-20
 * @Version: 1.0
 * Table: pear_project
 * Comment:
 * 项目表
 */
public class ProjectForNotifyNoReadsCountExample extends BaseExample {
    protected Integer limitClause;

    protected Integer countClause;

    protected Integer topClause;

    protected ProjectForNotifyNoReadsCount simple;

    protected String orderByClause;

    protected boolean distinct;

    protected List<Criteria> oredCriteria;

    public ProjectForNotifyNoReadsCountExample() {
        oredCriteria = new ArrayList<>();
        simple = new ProjectForNotifyNoReadsCount();
    }

    public void setLimitClause(Integer limitClause) {
        this.limitClause = limitClause;
    }

    public Integer getLimitClause() {
        return limitClause;
    }

    public void setCountClause(Integer countClause) {
        this.countClause = countClause;
    }

    public Integer getCountClause() {
        return countClause;
    }

    public void setTopClause(Integer topClause) {
        this.topClause = topClause;
    }

    public Integer getTopClause() {
        return topClause;
    }

    public void setSimple(ProjectForNotifyNoReadsCount simple) {
        this.simple = simple;
    }

    public ProjectForNotifyNoReadsCount getSimple() {
        return simple;
    }

    public void setOrderByClause(String orderByClause) {
        this.orderByClause = orderByClause;
    }

    public String getOrderByClause() {
        return orderByClause;
    }

    public void setDistinct(boolean distinct) {
        this.distinct = distinct;
    }

    public boolean isDistinct() {
        return distinct;
    }

    public List<Criteria> getOredCriteria() {
        return oredCriteria;
    }

    public void or(Criteria criteria) {
        oredCriteria.add(criteria);
    }

    public Criteria or() {
        Criteria criteria = createCriteriaInternal();
        oredCriteria.add(criteria);
        return criteria;
    }

    public Criteria createCriteria() {
        Criteria criteria = createCriteriaInternal();
        if (oredCriteria.size() == 0) {
            oredCriteria.add(criteria);
        }
        return criteria;
    }

    protected Criteria createCriteriaInternal() {
        Criteria criteria = new Criteria();
        return criteria;
    }

    public void clear() {
        oredCriteria.clear();
        orderByClause = null;
        distinct = false;
    }

    public static ProjectForNotifyNoReadsCountExample createExample(ProjectForNotifyNoReadsCount request) throws Exception {
        return createExample(request, null);
    }

    public static ProjectForNotifyNoReadsCountExample createExample(ProjectForNotifyNoReadsCount request, JSONObject options) throws Exception {
        ProjectForNotifyNoReadsCountExample example = new ProjectForNotifyNoReadsCountExample();
        example.setSimple(request);
        ProjectForNotifyNoReadsCountExample.Criteria criteria = example.createCriteria();

        example.fixExample(ProjectForNotifyNoReadsCount.class, CriteriaString.class, criteria, options);

        if (options != null) {
            String orderBy = "";
            if (options.containsKey("order_by")) {
                orderBy = setCriteriaOrderBy(options.getJSONArray("order_by"), example);
                if (orderBy.length() > 0) {
                    example.setOrderByClause(orderBy);
                }
            }
        }

        return example;
    }

    private static String setCriteriaOrderBy(JSONArray jsonArray, ProjectForNotifyNoReadsCountExample example) throws Exception {
        List<Object> request = Criterion.toList(jsonArray, CriteriaString.class);
        StringBuilder sb = new StringBuilder();
        int count = 0;
        for(int i = 0; i < request.size(); i++) {
            Object criteriaOrderByObj  = request.get(i);
            CriteriaString criteriaOrderBy = (CriteriaString)criteriaOrderByObj;
            int subCount = 0;

            subCount += appendCriteriaOrderByItem(sb, "`type`", criteriaOrderBy.getType());
            subCount += appendCriteriaOrderByItem(sb, "`count`", criteriaOrderBy.getCount());
            if (subCount > 1) {
                throw new Exception("order by数组元素对象属性多于1个(ProjectForNotifyNoReadsCountExample):"+count+","+JSON.toJSONString(jsonArray.get(i)));
            }
            if (subCount == 0 && !"{}".equals(JSON.toJSONString(jsonArray.get(i)))) {
                throw new Exception("存在非法order by 字段(ProjectForNotifyNoReadsCountExample):"+count+","+JSON.toJSONString(jsonArray.get(i)));
            }
            count++;
        }
        if (sb.length() == 0) {
            appendCriteriaOrderByItem(sb, "1", "");
        }

        return sb.toString();
    }

    protected abstract static class GeneratedCriteria {
        protected List<Criterion> criteria;

        protected GeneratedCriteria() {
            super();
            criteria = new ArrayList<>();
        }

        public boolean isValid() {
            return criteria.size() > 0;
        }

        public List<Criterion> getAllCriteria() {
            return criteria;
        }

        public List<Criterion> getCriteria() {
            return criteria;
        }

        protected void addCriterion(String condition) {
            if (condition == null) {
                throw new RuntimeException("Value for condition cannot be null");
            }
            criteria.add(new Criterion(condition));
        }

        protected void addCriterion(String condition, Object value, String property) {
            if (value == null) {
                throw new RuntimeException("Value for " + property + " cannot be null");
            }
            criteria.add(new Criterion(condition, value));
        }

        protected void addCriterion(String condition, Object value1, Object value2, String property) {
            if (value1 == null || value2 == null) {
                throw new RuntimeException("Between values for " + property + " cannot be null");
            }
            criteria.add(new Criterion(condition, value1, value2));
        }

        public Criteria andTypeIsNull() {
            addCriterion("`type` is null");
            return (Criteria) this;
        }

        public Criteria andTypeIsNotNull() {
            addCriterion("`type` is not null");
            return (Criteria) this;
        }

        public Criteria andTypeEqualTo(String value) {
            addCriterion("`type` =", value, "type");
            return (Criteria) this;
        }

        public Criteria andTypeNotEqualTo(String value) {
            addCriterion("`type` <>", value, "type");
            return (Criteria) this;
        }

        public Criteria andTypeGreaterThan(String value) {
            addCriterion("`type` >", value, "type");
            return (Criteria) this;
        }

        public Criteria andTypeGreaterThanOrEqualTo(String value) {
            addCriterion("`type` >=", value, "type");
            return (Criteria) this;
        }

        public Criteria andTypeLessThan(String value) {
            addCriterion("`type` <", value, "type");
            return (Criteria) this;
        }

        public Criteria andTypeLessThanOrEqualTo(String value) {
            addCriterion("`type` <=", value, "type");
            return (Criteria) this;
        }

        public Criteria andTypeRegexp(String value) {
            addCriterion("`type` regexp", value, "type");
            return (Criteria) this;
        }

        public Criteria andTypeLike(String value) {
            addCriterion("`type` like", value, "type");
            return (Criteria) this;
        }

        public Criteria andTypeNotLike(String value) {
            addCriterion("`type` not like", value, "type");
            return (Criteria) this;
        }

        public Criteria andTypeIn(List<String> values) {
            addCriterion("`type` in", values, "type");
            return (Criteria) this;
        }

        public Criteria andTypeNotIn(List<String> values) {
            addCriterion("`type` not in", values, "type");
            return (Criteria) this;
        }

        public Criteria andTypeBetween(String value1, String value2) {
            addCriterion("`type` between", value1, value2, "type");
            return (Criteria) this;
        }

        public Criteria andTypeNotBetween(String value1, String value2) {
            addCriterion("`type` not between", value1, value2, "type");
            return (Criteria) this;
        }

        public Criteria andCountIsNull() {
            addCriterion("`count` is null");
            return (Criteria) this;
        }

        public Criteria andCountIsNotNull() {
            addCriterion("`count` is not null");
            return (Criteria) this;
        }

        public Criteria andCountEqualTo(Long value) {
            addCriterion("`count` =", value, "count");
            return (Criteria) this;
        }

        public Criteria andCountNotEqualTo(Long value) {
            addCriterion("`count` <>", value, "count");
            return (Criteria) this;
        }

        public Criteria andCountGreaterThan(Long value) {
            addCriterion("`count` >", value, "count");
            return (Criteria) this;
        }

        public Criteria andCountGreaterThanOrEqualTo(Long value) {
            addCriterion("`count` >=", value, "count");
            return (Criteria) this;
        }

        public Criteria andCountLessThan(Long value) {
            addCriterion("`count` <", value, "count");
            return (Criteria) this;
        }

        public Criteria andCountLessThanOrEqualTo(Long value) {
            addCriterion("`count` <=", value, "count");
            return (Criteria) this;
        }

        public Criteria andCountIn(List<Long> values) {
            addCriterion("`count` in", values, "count");
            return (Criteria) this;
        }

        public Criteria andCountNotIn(List<Long> values) {
            addCriterion("`count` not in", values, "count");
            return (Criteria) this;
        }

        public Criteria andCountBetween(Long value1, Long value2) {
            addCriterion("`count` between", value1, value2, "count");
            return (Criteria) this;
        }

        public Criteria andCountNotBetween(Long value1, Long value2) {
            addCriterion("`count` not between", value1, value2, "count");
            return (Criteria) this;
        }

    }

    public static class CriteriaString {
        @JsonProperty("type")
        @JSONField(name = "type")
        private String type;

        public String getType() {
            return type;
        }
        
        public void setType(String _v) {
            type = _v;
        }

        @JsonProperty("count")
        @JSONField(name = "count")
        private String count;

        public String getCount() {
            return count;
        }
        
        public void setCount(String _v) {
            count = _v;
        }

    }

    public static class Criteria extends GeneratedCriteria {
        protected Criteria() {
            super();
        }
    }
}
